<?php
include __DIR__ . "/config/cors.php";
session_start();

$username = @$_COOKIE['username'];

if (isset($username)) {
    setcookie("username", null, time() - 3600, "/", "www.woniu-news.com", false, false);
    setcookie("role", null, time() - 3600, "/", "www.woniu-news.com", false, false);
    echo json_encode([
        "code" => 200,
        "message" => $username . " 已退出登录"
    ]);
} else {
    echo json_encode([
        "code" => 201,
        "message" => "您尚未登录"
    ]);
}

session_destroy();
